/*
 * @Description: 请假管理 - 接口
 * @Author: DHL
 * @Date: 2022-12-23 13:52:43
 * @LastEditors: DHL
 * @LastEditTime: 2022-12-23 13:52:43
 */

import { $get, $post, $put, $exportExcel } from '@/utils/http'
import { ContentTypeEnum } from '@/constant/http'
import {
  LeaveModel,
  LeaveParams,
  LeavePageParams,
  LeavePageResultModel,
  LeaveResultModel
} from './model/leaveModel'

/**
 * 分页查询
 */
export const apiLeaveSearch = (searchParams: LeavePageParams) =>
  $get<LeavePageResultModel>({
    url: '/leave/search',
    params: searchParams
  })

/**
 * 根据ID获取详情
 */
export const apiLeaveGetById = (id: string) =>
  $get<LeaveResultModel>({
    url: '/leave/getById',
    params: { id: id }
  })

/**
 * 保存信息
 */
export const apiLeaveSave = (saveParams: LeaveModel) =>
  $post<LeaveResultModel>({
    url: '/leave/save',
    contentType: ContentTypeEnum.json,
    params: saveParams
  })

/**
 * 更新信息
 */
export const apiLeaveUpdateById = (updateParams: LeaveModel) =>
  $put<LeaveResultModel>({
    url: '/leave/updateById',
    contentType: ContentTypeEnum.json,
    params: updateParams
  })

/**
 * 批量删除信息
 */
export const apiLeaveBatchDeleteByIds = (ids: string) =>
  $post<LeaveResultModel>({
    url: '/leave/batchDeleteByIds',
    params: { ids: ids }
  })

/**
 * 批量逻辑删除
 */
export const apiLeaveLogicBatchDeleteByIds = (ids: string) =>
  $post<LeaveResultModel>({
    url: '/leave/logicBatchDeleteByIds',
    params: { ids: ids }
  })

/**
 * 导出
 */
export const apiLeaveExport = (searchParams: LeaveParams, fileName: string) =>
  $exportExcel<LeaveResultModel>(
    {
      url: '/leave/exportExcel',
      params: searchParams
    },
    fileName
  )
